$( document ).on( "pagecreate", "#registrationPage", function( event ) {
	access_token=getQueryString("access_token");
//	alert($("#openId").val());
	$( "form" ).submit(function () {
		
		 var empNo = /^[0-9]{6}[0-9]*$/;
		 if(!empNo.test($("#empNo").val())){
			 $("#errorInfo").html("员工号输入有误，请重新输入");
			 $(".showInfo").show();
			 $("#empNo").val("");
			 return false;
		 }
		 
		var idNo=/^(\d{18,18}|\d{15,15}|\d{17,17}(x|X))$/;	
		if(!idNo.test($("#idNo").val())){
			$("#errorInfo").html("员工身份证号输入有误，请重新输入");
			 $(".showInfo").show();
			 $("#idNo").val("");
			 return false;
		 }
		 
		$.ajax({
		  	url: rootPath+"/emouser/bindEmpNo.do",
		  	type: "POST",
		  	dataType: "text",
			data: $("#register").serialize()+"&access_token="+access_token,//"bindForm={'empNo':'"+$("#empNo").val()+"','empIdNo':'"+$("#empIdNo").val()+"'}",//
		  	success: function( response ) {
//		  		alert(response);
		  		var data=$.parseJSON(response);
				if(data.state=="200"){
					access_toke=data.msg;
					//新鲜事
					var freshNews="http://www.minshenglife.com";
					alert_wx('success',"<a href='"+freshNews+"'>恭喜亲绑定成功,快去查看最新动态吧！</a>");
					$("#empNo").val("");
					$("#idNo").val("");
					//3秒后关闭当前页面
					setTimeout(function (){
						WeixinJSBridge.call('closeWindow');
					},1000);
					
				}else{
					alert_wx('fail',data.msg);
				}
		  	}
		});
		
		return false; // Prevent a form submit
	});	
});
